/*
 * lr-wpan-transactionList.h
 *
 *  Created on: 19 févr. 2012
 *      Author: stephane
 */

#ifndef LR_WPAN_TRANSACTIONLIST_H_
#define LR_WPAN_TRANSACTIONLIST_H_
#include "ns3/log.h"
#include "lr-wpan-mac.h"
#include "ns3/packet.h"


namespace ns3 {
/*
 * this class represents the transaction list bound to a device
 * it collects packet for indirect transmissions
 */
class LrWpanTransactionList :public Object
{

public:
	static TypeId GetTypeId(void);


	LrWpanTransactionList(void);

	~LrWpanTransactionList(void);

// this function checks the number of packet corresponding to a given device indicated by the address and the addressMode
	int search(Address add, LrWpanAddressMode addType);

// this function return the first packet corresponding to the device indicated by address and addresmodeType
	Ptr<Packet> get(Address add, LrWpanAddressMode addType);				//try to use the search only

/*
 * this method allow me to search for a packet corresponding to a given device indicated by the parameters
 * address and addressMode, plus the difference with the get is that the update set the pending  of the packet to one in case of multiples packets
 * corresponding to the same address
 */
	Ptr<Packet> Update(Address add, LrWpanAddressMode addType);
	void add(Ptr<Packet> pkt);

	bool isfull() const;
	bool isEmpty() const;



	void setMac(Ptr<LrWpanMac> mac);

	void cancelTransaction();


private:

	void DoDispose(void);


	std::list<Ptr<Packet> > m_transactions;
	uint16_t m_macTransactionPersistenceTime;
	double m_rate;
	const static uint8_t max_transaction;
	Ptr<LrWpanMac> m_mac;
};



}



  // namespace ns3
#endif /* LR_WPAN_TRANSACTIONLIST_H_ */
